package com.app.miwawa.cui.system;

import org.apache.log4j.Logger;
import org.framework.common.cui.AbstractController;
import org.framework.common.ext.exception.CommonException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.app.miwawa.api.system.entity.center.Shops;
import com.app.miwawa.api.system.service.bo.ShopsBo;

/**
 * 早教门店控制器类
 * <p>描述: </p>
 * <p>Company: Professional</p>
 * @author chanlong(陈龙)
 * @date 2016年1月13日 下午3:30:30
 * @version 1.0.2016
 */
@RestController
public class ShopsController extends AbstractController {

	private Logger log = Logger.getLogger(ShopsController.class);
	
	@Autowired
	private ShopsBo shopsBo;
	
	@RequestMapping("/{dbname}/shops/save")
	public Object save(@PathVariable final String dbname, @ModelAttribute final Shops entity) throws Exception {
		if(check(dbname)) return error("提交参数有误，请检查数据源或参数绑定源！");
		
		try{
			// 注册数据源
			registerDataSource(dbname);
			
			// 保存实体对象
			return shopsBo.insert(entity);
		} catch (Exception e) {
			e.printStackTrace();
			throw new CommonException(log, "保存实体对象失败！");
		}
	}
}
